#include <iostream>
#include <algorithm>
#include <time.h>
#include <math.h>
using namespace std;

#define forn(i,n) for(int i=0;i<n;i++)
unsigned long long contador;			// Cuenta la cantidad de operaciones

void print(double* a, int l){			// solo para debug. Imprime un vector.
	cout << "<";
	forn(i,l){
		if(i!=0) cout << ",";
		cout << a[i];
	}
	cout << ">" << endl;
}

void merge_sort(double* a, int n){
	if( n==2 && a[0]>a[1] ){
		double temp = a[0];
		a[0] =  a[1];
		a[1] =  temp;
		contador += 5;
	}else if(n>2){

		/* Divide */
		int l = n/2;
		merge_sort(a,l);
		merge_sort(a+l,n-l);
		contador += 9;

		/* Merge */
		double b[n];
		int i = 0; int j = l;
		contador += 3;
		forn(k,n){
			if(i>=l){
				b[k] = a[j];
				j++;
				contador += 2;
			}else if(j>=n){
				b[k] = a[i];
				i++;
				contador += 2;
			}else if(a[i]<=a[j]){
				b[k] = a[i];
				i++;
				contador += 2;
			}else{
				b[k] = a[j];
				j++;
				contador += 2;
			}
		}
		forn(i,n) a[i] = b[i];
		contador += n;
	}
}

int intervalos(double* a,int n){
	if(n==0) return 0;
	merge_sort(a,n);
	double upper = a[0]+1;
	int intervalos = 1;
	contador+=3;
	forn(i,n) if(a[i]>upper){
		upper = a[i] + 1;
		intervalos++;
		contador += 2;
	}
	return intervalos;
}

int main(int argc, char** argv){
	int n;
	while(cin >> n && n!=-1){
		double a[n];
		forn(i,n) cin >> a[i];

		if(argc>1 && string(argv[1])=="time"){
			float sec = argc>2 ? atof(argv[2]) : 0.5;	// minimo tiempo de ejecucion (para mas precision)
			int tries = argc>3 ? atoi(argv[3]) : 1;		// las veces que hago el timing (para minimizar error)
			clock_t start,end;
			forn(t,tries){
				start = clock();
				long long c = 0;
				while( (double)(clock()-start)/CLOCKS_PER_SEC<sec ){
					intervalos(a,n);
					c++;
				}
				end = clock();
				double t = (double)(end-start)/(CLOCKS_PER_SEC*c);
				printf("%.8f ",t); // 8 decimales de precision
			}
			cout << endl;
		}else if(argc>1 && string(argv[1])=="count"){
			contador = 0;
			intervalos(a,n);
			cout << contador << endl;
		}else{
			cout <<  intervalos(a,n) << endl;
		}

	}
	return 0;
}
